import 'package:flutter/material.dart';

import '../pages/tabs/Tabs.dart';
import '../pages/tabs/Home.dart';
import '../pages/tabs/Category.dart';
import '../pages/tabs/Member.dart';
import '../pages/search/Search.dart';
import '../pages/book/Book.dart';
import '../pages/book/Content.dart';
import '../pages/book/List.dart';
import '../pages/member/Login.dart';
import '../pages/member/Register.dart';


final Map<String, Function> routes = {
  '/index': (contxt) => Tabs(),
  '/home': (contxt) => HomePage(),
  '/category': (contxt) => CategoryPage(),
  '/member': (contxt) => MemberPage(),
  '/login': (contxt) => LoginPage(),
  '/register': (contxt) => RegisterPage(),
  '/search': (contxt, {arguments}) => SearchPage(arguments: arguments),
  '/book': (contxt, {arguments}) => BookPage(arguments: arguments),
  '/content': (contxt, {arguments}) =>ContentPage(arguments: arguments),
  '/list': (contxt, {arguments}) =>ListPage(arguments: arguments),
};

// ignore: missing_return, top_level_function_literal_block
var onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  final String name = settings.name;
  final Function pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) => pageContentBuilder(context,
              arguments: settings.arguments));
      return route;
    } else {
      final Route route = MaterialPageRoute(
          builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};